package edu.cuc.learningAkka.chap1;

import akka.actor.AbstractActor;
import akka.event.Logging;
import akka.event.LoggingAdapter;
import akka.japi.pf.ReceiveBuilder;

import java.util.HashMap;
import java.util.Map;

/**
 * Created by bingruiqi on 2017/9/8.
 */
public class AkkademyDb extends AbstractActor {
    protected Map<String, Object> map = new HashMap<String, Object>();
    protected LoggingAdapter log = Logging.getLogger(context().system(), AkkademyDb.class);

    private AkkademyDb() {
        receive(ReceiveBuilder.match(SetRequest.class, message ->
        {
            log.info("receive message {}", message);
            map.put(message.getKey(), message.getValue());

        }).matchAny(o -> log.info("receive unknow message", o)).build());
    }
}
